<?php
include 'islogin.php';
include '../config.php';
	
if( isset($_GET['flag']))
{
	if($_GET['flag']=="update")
	{
		 $sql = "select id,title,remark,dates,type_ from en_question where flag =1 and id=".$_GET['id'];
		$result = mysql_query($sql);
		$row = mysql_fetch_array($result);
	}
}
if(isset($_POST['flag']))
{
	if($_POST['flag']=="update")
	{
		$sql = "update en_question set title='".$_POST['title']."', dates='".$_POST['dates']."', remark ='".$_POST['remark']."',type_ =".$_POST['type_']." where id =".$_POST['id'];
		mysql_query($sql);
		echo $sql;
		echo "<script>window.location.href='question_list.php'</script>";
	}
	if($_POST['flag']=="add")
	{
		$sql = "insert into en_question(title,remark,dates,type_,flag) values('".$_POST['title']."','".$_POST['remark']."','".$_POST['dates']."',".$_POST['type_'].",1)";
		
		mysql_query($sql);
		echo "<script>window.location.href='question_list.php'</script>";
	}
	
}
?>
<script src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="js/ckfinder/ckfinder.js"></script>
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css"/>
<script>
	
		
</script>
<div style="border:0px solid red;"> 

    	<div id="top"><div>常见问题</div></div>
    	
	    <div id="middle">
	     <div class="layout">
		  	<div class="title">问题管理</div>
		       <div class="content">
			       <form action="question_add.php" method="post">
			         <input type="hidden" name="flag" value="<?php if(isset($row)){echo "update";}else{echo "add";}?>" />
			         <input type="hidden" name="id" value="<?php if(isset($row)){echo $row['id'];}?>" />
			          <table  cellspacing="0" cellpadding="0">  
			          	<tr>
			          		<td class="title_some_td" style="width:100px;">标题:</td>
			          		<td><input name="title" value="<?php if(isset($row)){echo $row['title'];}?>"  /></td>
			          	</tr>
			      
			          
			        
			          	<tr>
			          		<td class="title_some_td" style="width:100px;">日期:</td>
			          		<td><input name="dates" value="<?php if(isset($row)){echo $row['dates'];}?>"  /><span>格式:2012-02-02</span></td>
			          	</tr>
			          	<tr>
			          		<td class="title_some_td" style="width:100px;">类型:</td>
			          		<td>
			          			
			          			<select name="type_">
			          				<option value="1" <?php if(isset($row)&&$row['type_']==1){echo "selected";}?>>常见问题</option>
			          				<option value="2" <?php if(isset($row)&&$row['type_']==2){echo "selected";}?>>产品问题</option>
			          			</select>
			          		</td>
			          	</tr>
			          	
			          	 <tr>
			          		<td class="title_some_td" style="width:100px;">问题正文:</td>
			          		<td>
			          			<textarea style="" rows="5" cols="30" name="remark" id="remark"><?php if(isset($row)){echo $row['remark'];}?></textarea>
			          		</td>
			          		<script type="text/javascript">
									var editor =CKEDITOR.replace( 'remark',
									{
										skin : 'kama',
										filebrowserImageUploadUrl : 'js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'
									});
									
						</script>
			          	</tr>
			          	<tr>
			          		<td></td>
			          		<td><input type="submit" value="保存" /></td>
			          	</tr>
			          </table>
			      </form>    
		      </div>
		  </div>
	    </div>
	    
	    <div id="bottom"></div>		
</div>	    